Skip to content

docs: import os in the opening usage example - #612

Merged
nicoddemus merged 1 commit into
pytest-dev:mainfrom
agammann:docs/import-os-in-usage-example
Sep 23, 2026
Merged

nicoddemus merged 1 commit into
pytest-dev:mainfrom
agammann:docs/import-os-in-usage-example

Conversation

@agammann

Copy link
Copy Markdown
Contributor

The opening usage example calls mocker.patch.object(os, "listdir", autospec=True) without importing os, so copying it into a test module raises NameError.

Add the import to make the example runnable as shown.

Validation: extracted the original and corrected snippets into temporary test modules and ran them with pytest and this checkout's mocker fixture. The original fails with NameError: name 'os' is not defined; the corrected example passes. The strict Sphinx HTML build also passes.

@nicoddemus
nicoddemus merged commit e24c334 into pytest-dev:main Sep 23, 2026
18 checks passed
@nicoddemus

Copy link
Copy Markdown
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants